package com.wjjun.customview.views;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wjjun.viewmodel.BannerItemViewModel;
import com.youth.banner.loader.ImageLoader;

/**
 * banner使用的图片加载器
 * Created by 67535 on 2018/4/29.
 */
public class GlideImageLoader extends ImageLoader {

    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        if (path == null) {
            return;
        }
        //Glide 加载图片简单用法
        if (path instanceof BannerItemViewModel && TextUtils.isEmpty(((BannerItemViewModel) path).getPic())
                && ((BannerItemViewModel) path).getResId() != 0) {
            Glide.with(context).load(context.getResources().getDrawable(((BannerItemViewModel) path).getResId()))
                    .into(imageView);
        } else if (!TextUtils.isEmpty(path.toString())) {
            Glide.with(context).load(path.toString()).into(imageView);
        }
    }
}
